//
//  UILabel+Extension.swift
//  Weibo
//
//  Created by HM on 16/5/23.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

extension UILabel {
    //给UILabel 添加一个便利的构造函数
    convenience init(title: String,font: CGFloat,textColor: UIColor,alignment: NSTextAlignment = .Center) {
        
        //调用指定的构造函数 实例化对象
        self.init()
        self.text = title
        self.font = UIFont.systemFontOfSize(font)
        self.textColor = textColor
        textAlignment = alignment
        //设置自动换行
        if alignment == .Left {
            //设置最大布局宽度
            preferredMaxLayoutWidth = ScreenWidth - 2 * StatusCellMargin
        }
        numberOfLines = 0
        //自适应大小
        sizeToFit()
    }
}
